package com.cyys.modules.system.model.param;

import com.cyys.common.validate.Edit;
import com.cyys.common.validate.Insert;
import com.cyys.modules.core.model.CoreBean;
import com.cyys.modules.core.sysParam.ParamBasicUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;

import javax.validation.constraints.NotBlank;

@Data
public class ParamBasicType extends CoreBean {

	/**
	 * 大类参数编号
	 */
	@NotBlank(message = "大类参数ID不能为空",groups = {Edit.class, Insert.class})
	private String basicId;

	/**
	 * 键
	 */
	@NotBlank(message = "键不能为空",groups = {Edit.class, Insert.class})
	private String paramKey;
	/**
	 * 值
	 */
	@NotBlank(message = "值不能为空",groups = {Edit.class, Insert.class})
	private String paramValue;
	
	/**
	 * 描述
	 */
	private String desp;

	/**
	 * 排序
	 */
	private Integer sort;

	@JsonIgnore
	public String getBasicName() {
		if(basicId != null){
			Object object = ParamBasicUtil.getParamBasic().get(String.valueOf(basicId));
			if( object != null){
				return object.toString();
			}
		}
		return "";
	}
}
